<template>
  <el-form ref="form" :inline="true" :model="form">
    <template v-for="(item,index) in items">
      <template v-if="['text','number'].indexOf(item.type) !=-1">
        <el-form-item :prop="item.name" :label="item.label" :key="index">
          <el-input style="width: 200px;" v-model="form[item.name]" :placeholder="item.placeholder"></el-input>
        </el-form-item>
      </template>
      <template v-if="['select'].indexOf(item.type) !=-1">
        <el-form-item :prop="item.name" :label="item.label" :key="index">
          <el-select   style="width: 200px;" v-model="form[item.name]" :placeholder="item.placeholder">
            <el-option
                v-for="item in item.options"
                :key="item.value"
                :label="item.label"
                :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
      </template>
    </template>
    <el-form-item>
      <el-button @click="$emit('search')" icon="el-icon-search">查询</el-button>
      <el-button @click="resetField" icon="el-icon-search">重置</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
  export default {
    name: "RQueryForm",
    props:{
      items:{
        type:Array,
        default:()=>{}
      },
      form:{
        type:Object,
        default:()=>{}
      }
    },
    methods:{
      resetField(){
        console.log(this.$refs['form'])
        this.$refs['form'].resetFields();
      },
    }

  }
</script>

<style scoped>

</style>